home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Blender 2.49b / blender-2.49b-windows.exe / $_4_ / .blender / scripts / discombobulator.py < prev    next >
Text File  |  2009-08-31  |  53KB  |  1,527 lines

  1. #!BPY
  2.  
  3. """
  4. Name: 'Discombobulator'
  5. Blender: 237
  6. Group: 'Mesh'
  7. Tip: 'Adds random geometry to a mesh'
  8. """
  9.  
  10. __author__ = "Evan J. Rosky (syrux)"
  11. __url__ = ("Script's homepage, http://evan.nerdsofparadise.com/programs/discombobulator/index.html")
  12. __version__ = "237"
  13. __bpydoc__ = """\
  14. Discombobulator adds random geometry to a mesh.
  15.  
  16. As an example, this script can easily give a "high-tech"
  17. look to walls and spaceships.
  18.  
  19. Definitions:<br>
  20.   - Protrusions: extrusions of each original face on the mesh.
  21. You may have from 1 to 4 protrusions on each face.<br>
  22.   - Taper: The tips of each protrusion will be a percentage
  23. smaller than the base.<br>
  24.   - Doodads: small extruded blocks/shapes that are randomly placed
  25. about the top of a protrusion or face.
  26.  
  27.  
  28. Usage:<br>
  29.   Input your settings, make sure the mesh you would like to modify
  30. is selected (active) and then click on "Discombobulate".<br>
  31.   See the scripts tutorial page (on the homepage) for more info.
  32.  
  33.  
  34. New Features:<br>
  35.   - Will use existing materials if there are any.<br>
  36.   - Clicking "Assign materials by part" will allow assigning
  37. of different material indices to Protrusion or Doodad Sides
  38. and Tops in the gui element below it.<br>
  39.   - Setting a material index to 0 will use whatever material
  40. is assigned to the face that is discombobulated.
  41.   - You can now scroll using the arrow keys.
  42.  
  43.  
  44. Notes:<br>
  45.   - Modifications can be restricted to selected faces
  46. by setting "Only selected faces" for protrusions and/or
  47. doodads.<br>
  48.   - It's possible to restrict mesh generation to add only
  49. protrusions or only doodads instead of both.<br>
  50.   - You may also choose to have Discombobulator select the
  51. tops of created protrusions by clicking the corresponding
  52. number of protrusion buttons under "Select Tops". You may 
  53. also do the same for doodads by choosing "Select Doodads" and
  54. "Only Select Tops". You may choose to select the whole doodads 
  55. by leaving "Only Select Tops" off.<br>
  56.   - By selecting "Deselect Selected" you can have
  57. discombobulator deselect everything but the selections it
  58. makes.<br>
  59.   - The "Face %" option will set the percentage of faces that
  60. will be modified either for the doodads or the protrusions.<br>
  61.   - "Copy Before Modifying" will create a new object with the
  62. modifications where leaving it off will overwrite the original
  63. mesh.<br>
  64.  
  65. You can find more information at the Link above.
  66. """
  67.  
  68.  
  69. # $Id: discombobulator.py 10610 2007-04-29 13:39:46Z campbellbarton $
  70. # Updated 2006-09-26
  71. # Changes since last version: 
  72. #     > Works with Blender CVS and hopefully with Blender 2.40.
  73. #     > Swaps min/max values when min>max rather than complaining.
  74. #     > Will keep previously assigned materials.
  75. #     > Now allows user to assign custom material indices to
  76. #            Protrusion and Doodad Sides and Tops.
  77. #     > The initial Gui Layout will change depending on the aspect
  78. #            ratio of the window it is in.
  79. #     > Using the arrow keys will scroll the gui.
  80. # --------------------------------------------------------------------------
  81. # Discombobulator v2.1b
  82. # by Evan J. Rosky, 2005
  83. # This plugin is protected by the GPL: Gnu Public Licence
  84. # GPL - http://www.gnu.org/copyleft/gpl.html
  85. # --------------------------------------------------------------------------
  86. # ***** BEGIN GPL LICENSE BLOCK *****
  87. #
  88. # Copyright (C) 2005: Evan J. Rosky
  89. #
  90. # This program is free software; you can redistribute it and/or
  91. # modify it under the terms of the GNU General Public License
  92. # as published by the Free Software Foundation; either version 2
  93. # of the License, or (at your option) any later version.
  94. #
  95. # This program is distributed in the hope that it will be useful,
  96. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  97. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
  98. # GNU General Public License for more details.
  99. #
  100. # You should have received a copy of the GNU General Public License
  101. # along with this program; if not, write to the Free Software Foundation,
  102. # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  103. #
  104. # ***** END GPL LICENCE BLOCK *****
  105. # --------------------------------------------------------------------------
  106.  
  107. #Hit Alt-P to run
  108.  
  109. import Blender
  110. from Blender import NMesh,Object,Material,Window,Types,Scene
  111. from Blender.NMesh import Vert,Face
  112. from Blender.Mathutils import *
  113.  
  114. import defaultdoodads
  115. import BPyMathutils
  116. from BPyMathutils import genrand
  117. a = BPyMathutils.sgenrand(int(round(Rand(1000,99999),0)))
  118.  
  119. #Create random numbers
  120. def randnum(low,high):
  121.     num = genrand()
  122.     num = num*(high-low)
  123.     num = num+low
  124.     return num
  125.  
  126. #Object Vars
  127. newmesh = NMesh.GetRaw()
  128. materialArray = [0]
  129.  
  130. #Material Vars
  131. reassignMats = 0
  132. protSideMat = 1
  133. protTopMat = 2
  134. doodSideMat = 3
  135. doodTopMat = 4
  136. thereAreMats = 0
  137. currmat = 0
  138.  
  139. #Global Vars
  140. makenewobj = 1
  141. errortext = "Remember to select an object."
  142. editmode = 0
  143.  
  144. #Protrusion Vars
  145. makeprots = 1
  146. faceschangedpercent = 1.0
  147. minimumheight = 0.2
  148. maximumheight = 0.4
  149. subface1 = 1
  150. subface2 = 1
  151. subface3 = 1
  152. subface4 = 1
  153. subfaceArray = [1,2,3,4]
  154. minsubfaces = 1
  155. minimumtaperpercent = 0.15
  156. maximumtaperpercent = 0.35
  157. useselectedfaces = 0
  158. selectface1 = 1
  159. selectface2 = 1
  160. selectface3 = 1
  161. selectface4 = 1
  162. deselface = 1
  163.  
  164. #Doodad Vars
  165. makedoodads = 1
  166. doodadfacepercent = 1.0
  167. selectdoodad = 0
  168. onlyonprotrusions = 0
  169. doodonselectedfaces = 0
  170. selectdoodadtoponly = 0
  171. doodad1 = 1
  172. doodad2 = 1
  173. doodad3 = 1
  174. doodad4 = 1
  175. doodad5 = 1
  176. doodad6 = 1
  177. doodadminperface = 2
  178. doodadmaxperface = 6
  179. doodadminsize = 0.15
  180. doodadmaxsize = 0.45
  181. doodadminheight = 0.0
  182. doodadmaxheight = 0.1
  183. doodadArray = [1,2,3,4,5,6]
  184.  
  185. def makeSubfaceArray():
  186.     global subfaceArray
  187.     global subface1
  188.     global subface2
  189.     global subface3
  190.     global subface4
  191.     
  192.     subfaceArray = []
  193.     if subface1 > 0:
  194.         subfaceArray.append(1)
  195.     if subface2 > 0:
  196.         subfaceArray.append(2)
  197.     if subface3 > 0:
  198.         subfaceArray.append(3)
  199.     if subface4 > 0:
  200.         subfaceArray.append(4)
  201.  
  202. def makeDoodadArray():
  203.     global doodadArray
  204.     global doodad1
  205.     global doodad2
  206.     global doodad3
  207.     global doodad4
  208.     global doodad5
  209.     global doodad6
  210.     
  211.     doodadArray = []
  212.     if doodad1 > 0:
  213.         doodadArray.append(1)
  214.     if doodad2 > 0:
  215.         doodadArray.append(2)
  216.     if doodad3 > 0:
  217.         doodadArray.append(3)
  218.     if doodad4 > 0:
  219.         doodadArray.append(4)
  220.     if doodad5 > 0:
  221.         doodadArray.append(5)
  222.     if doodad6 > 0:
  223.         doodadArray.append(6)
  224.  
  225. def extrude(mid,nor,protrusion,v1,v2,v3,v4,tosel=1,flipnor=0):
  226.     taper = 1 - randnum(minimumtaperpercent,maximumtaperpercent)
  227.     newmesh_verts = newmesh.verts
  228.     newmesh_faces = newmesh.faces
  229.     
  230.     vert = newmesh_verts[v1]
  231.     point = (vert.co - mid)*taper + mid + protrusion*Vector(nor)
  232.     ver = Vert(point[0],point[1],point[2])
  233.     ver.sel = tosel
  234.     newmesh_verts.append(ver)
  235.     vert = newmesh_verts[v2]
  236.     point = (vert.co - mid)*taper + mid + protrusion*Vector(nor)
  237.     ver = Vert(point[0],point[1],point[2])
  238.     ver.sel = tosel
  239.     newmesh_verts.append(ver)
  240.     vert = newmesh_verts[v3]
  241.     point = (vert.co - mid)*taper + mid + protrusion*Vector(nor)
  242.     ver = Vert(point[0],point[1],point[2])
  243.     ver.sel = tosel
  244.     newmesh_verts.append(ver)
  245.     vert = newmesh_verts[v4]
  246.     point = (vert.co - mid)*taper + mid + protrusion*Vector(nor)
  247.     ver = Vert(point[0],point[1],point[2])
  248.     ver.sel = tosel
  249.     newmesh_verts.append(ver)
  250.     
  251.     faceindex = len(newmesh_verts) - 4
  252.     
  253.     #side face 1
  254.     face = Face([newmesh_verts[v1], newmesh_verts[v2], newmesh_verts[faceindex+1], newmesh_verts[faceindex]])
  255.     if flipnor != 0:
  256.         face.v.reverse()
  257.     if thereAreMats == 1:
  258.         if reassignMats == 0 or protSideMat == 0:
  259.             face.materialIndex = currmat
  260.         else:
  261.             face.materialIndex = protSideMat-1
  262.     newmesh_faces.append(face)
  263.     
  264.     #side face 2
  265.     face = Face([newmesh_verts[v2], newmesh_verts[v3], newmesh_verts[faceindex+2], newmesh_verts[faceindex+1]])
  266.     if flipnor != 0:
  267.         face.v.reverse()
  268.     if thereAreMats == 1:
  269.         if reassignMats == 0 or protSideMat == 0:
  270.             face.materialIndex = currmat
  271.         else:
  272.             face.materialIndex = protSideMat-1
  273.     newmesh_faces.append(face)
  274.     
  275.     #side face 3
  276.     face = Face([newmesh_verts[v3], newmesh_verts[v4], newmesh_verts[faceindex+3], newmesh_verts[faceindex+2]])
  277.     if flipnor != 0:
  278.         face.v.reverse()
  279.     if thereAreMats == 1:
  280.         if reassignMats == 0 or protSideMat == 0:
  281.             face.materialIndex = currmat
  282.         else:
  283.             face.materialIndex = protSideMat-1
  284.     newmesh_faces.append(face)
  285.     
  286.     #side face 4
  287.     face = Face([newmesh_verts[v4], newmesh_verts[v1], newmesh_verts[faceindex], newmesh_verts[faceindex+3]])
  288.     if flipnor != 0:
  289.         face.v.reverse()
  290.     if thereAreMats == 1:
  291.         if reassignMats == 0 or protSideMat == 0:
  292.             face.materialIndex = currmat
  293.         else:
  294.             face.materialIndex = protSideMat-1
  295.     newmesh_faces.append(face)
  296.     
  297.     #top face    
  298.     face = Face(newmesh_verts[-4:])
  299.     if flipnor != 0:
  300.         face.v.reverse()
  301.     if tosel == 1:
  302.         face.sel = 1
  303.     if thereAreMats == 1:
  304.         if reassignMats == 0 or protTopMat == 0:
  305.             face.materialIndex = currmat
  306.         else:
  307.             face.materialIndex = protTopMat-1
  308.     newmesh_faces.append(face)
  309.     return face
  310.  
  311. #Sets the global protrusion values
  312. def setProtrusionValues(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15):
  313.     
  314.     #Protrusions
  315.     global makeprots
  316.     global minimumtaperpercent
  317.     global maximumtaperpercent
  318.     global faceschangedpercent
  319.     global minimumheight
  320.     global maximumheight
  321.     global subface1
  322.     global subface2
  323.     global subface3
  324.     global subface4
  325.     global useselectedfaces
  326.     global selectface1
  327.     global selectface2
  328.     global selectface3
  329.     global selectface4
  330.     global deselface
  331.     global subfaceArray
  332.     
  333.     #Protrusions
  334.     makeprots = p0
  335.     faceschangedpercent = p1
  336.     minimumheight = p2
  337.     maximumheight = p3
  338.     subface1 = p4
  339.     subface2 = p5
  340.     subface3 = p6
  341.     subface4 = p7
  342.     minimumtaperpercent = p8
  343.     maximumtaperpercent = p9
  344.     useselectedfaces = p10
  345.     selectface1 = p11
  346.     selectface2 = p12
  347.     selectface3 = p13
  348.     selectface4 = p14
  349.     deselface = p15
  350.     makeSubfaceArray()
  351.     if len(subfaceArray) == 0:
  352.         makeprots = 0
  353.     
  354.     if minimumheight > maximumheight:
  355.         a = maximumheight
  356.         maximimheight = minimumheight
  357.         minimumheight = a
  358.     elif minimumtaperpercent > maximumtaperpercent:
  359.         a = maximumtaperpercent
  360.         maximimtaperpercent = minimumtaperpercent
  361.         minimumtaperpercent = a
  362.  
  363. #Sets the global Doodad values
  364. def setDoodadValues(d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17):
  365.     
  366.     #Doodads
  367.     global makedoodads
  368.     global doodadfacepercent
  369.     global selectdoodad
  370.     global onlyonprotrusions
  371.     global doodad1
  372.     global doodad2
  373.     global doodad3
  374.     global doodad4
  375.     global doodad5
  376.     global doodad6
  377.     global doodadminperface
  378.     global doodadmaxperface
  379.     global doodadminsize
  380.     global doodadmaxsize
  381.     global doodadminheight
  382.     global doodadmaxheight
  383.     global doodadArray
  384.     global doodonselectedfaces
  385.     global selectdoodadtoponly
  386.     
  387.     #Doodads
  388.     makedoodads = d0
  389.     doodadfacepercent = d1
  390.     selectdoodad = d2
  391.     onlyonprotrusions = d3
  392.     doodad1 = d4
  393.     doodad2 = d5
  394.     doodad3 = d6
  395.     doodad4 = d7
  396.     doodad5 = d8
  397.     doodad6 = d9
  398.     doodadminperface = d10
  399.     doodadmaxperface = d11
  400.     doodadminsize = d12
  401.     doodadmaxsize = d13
  402.     doodadminheight = d14
  403.     doodadmaxheight = d15
  404.     doodonselectedfaces = d16
  405.     selectdoodadtoponly = d17
  406.     makeDoodadArray()
  407.     if len(doodadArray) == 0:
  408.         makedoodads = 0
  409.     
  410.     elif doodadminperface > doodadmaxperface:
  411.         a = doodadmaxperface
  412.         doodadmaxperface = doodadminperface
  413.         doodadminperface = a
  414.     elif doodadminsize > doodadmaxsize:
  415.         a = doodadmaxsize
  416.         doodadmaxsize = doodadminsize
  417.         doodadminsize = a
  418.     elif doodadminheight > doodadmaxheight:
  419.         a = doodadmaxheight
  420.         doodadmaxheight = doodadminheight
  421.         doodadminheight = a
  422.  
  423. #Sets other global values
  424. def setOtherValues(g0,m0,m1,m2,m3,m4):
  425.     
  426.     #Global
  427.     global reassignMats
  428.     global makenewobj
  429.     global protSideMat
  430.     global protTopMat
  431.     global doodSideMat
  432.     global doodTopMat
  433.     
  434.     #Get Misc Variables
  435.     makenewobj = g0
  436.     reassignMats = m0
  437.     protSideMat = m1
  438.     protTopMat = m2
  439.     doodSideMat = m3
  440.     doodTopMat = m4
  441.  
  442. def discombobulate():
  443.     
  444.     #Global
  445.     global origmesh
  446.     global newmesh
  447.     global makenewobj
  448.     global origobj
  449.     global newobj
  450.     global messagetext
  451.     global errortext
  452.     global editmode
  453.     
  454.     #Protrusions
  455.     global makeprots
  456.     global minimumtaperpercent
  457.     global maximumtaperpercent
  458.     global faceschangedpercent
  459.     global minimumheight
  460.     global maximumheight
  461.     global subface1
  462.     global subface2
  463.     global subface3
  464.     global subface4
  465.     global useselectedfaces
  466.     global selectface1
  467.     global selectface2
  468.     global selectface3
  469.     global selectface4
  470.     global deselface
  471.     global subfaceArray
  472.     
  473.     #Doodads
  474.     global makedoodads
  475.     global doodadfacepercent
  476.     global selectdoodad
  477.     global onlyonprotrusions
  478.     global doodad1
  479.     global doodad2
  480.     global doodad3
  481.     global doodad4
  482.     global doodad5
  483.     global doodad6
  484.     global doodadminperface
  485.     global doodadmaxperface
  486.     global doodadminsize
  487.     global doodadmaxsize
  488.     global doodadminheight
  489.     global doodadmaxheight
  490.     global doodadArray
  491.     global doodonselectedfaces
  492.     global selectdoodadtoponly
  493.     
  494.     #Global
  495.     global materialArray
  496.     global reassignMats
  497.     global protSideMat
  498.     global protTopMat
  499.     global doodSideMat
  500.     global doodTopMat
  501.     global thereAreMats
  502.     global currmat
  503.     
  504.     origobj = Scene.GetCurrent().objects.active
  505.     if not origobj:
  506.         glRasterPos2d(10,50)
  507.         errortext = "YOU MUST SELECT AN OBJECT!"
  508.         messagetext = ErrorText(errortext)
  509.         Blender.Redraw()
  510.         return
  511.  
  512.     #Leave Editmode
  513.     editmode = Window.EditMode()
  514.     if editmode: Window.EditMode(0)
  515.  
  516.     #Get Major Variables
  517.     
  518.     origmesh = origobj.getData()
  519.     
  520.     if origobj.type != 'Mesh':
  521.         glRasterPos2d(10,50)
  522.         errortext = "OBJECT MUST BE MESH!"
  523.         messagetext = ErrorText(errortext)
  524.         Blender.Redraw()
  525.         return
  526.     
  527.     newmesh = NMesh.GetRaw()
  528.     materialArray = origmesh.getMaterials()
  529.     if len(materialArray) < 1:
  530.         thereAreMats = 0
  531.     else:
  532.         thereAreMats = 1
  533.     
  534.     #add material indices if necessary (only up to 4)
  535.     if thereAreMats == 1 and reassignMats == 1:
  536.         if len(materialArray) < 4:
  537.             if protSideMat > 4: protSideMat = 4
  538.             if protTopMat > 4: protTopMat = 4
  539.             if doodSideMat > 4: doodSideMat = 4
  540.             if doodTopMat > 4: doodTopMat = 4
  541.         else:
  542.             if protSideMat > len(materialArray): protSideMat = len(materialArray)
  543.             if protTopMat > len(materialArray): protTopMat = len(materialArray)
  544.             if doodSideMat > len(materialArray): doodSideMat = len(materialArray)
  545.             if doodTopMat > len(materialArray): doodTopMat = len(materialArray)
  546.         
  547.         #This only does something if there are less than 4 verts
  548.         for matind in [protSideMat,protTopMat,doodSideMat,doodTopMat]:
  549.             if matind > len(materialArray) and matind <= 4:
  550.                 for i in xrange(len(materialArray),matind+1):
  551.                     materialArray.append(Material.New("AddedMat " + str(i)))
  552.                     
  553.     #Sets the materials
  554.     newmesh.setMaterials(materialArray)
  555.     
  556.     #Set the doodad settings
  557.     defaultdoodads.settings(selectdoodadtoponly,materialArray,reassignMats,thereAreMats,doodSideMat,doodTopMat)
  558.     #defaultdoodads.settings(selectdoodadtoponly,materialArray,reassignMats,thereAreMats,currmat)
  559.     
  560.     newmesh.verts.extend(origmesh.verts)
  561.     
  562.     #Start modifying faces
  563.     for currface in origmesh.faces:
  564.         
  565.         currmat = currface.materialIndex
  566.         defaultdoodads.setCurrMat(currmat)
  567.         
  568.         #Check if it is a triangle
  569.         if len(currface.v)<4:
  570.             face = Face([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index]])
  571.             if thereAreMats == 1:
  572.                 face.materialIndex = currmat
  573.             newmesh.faces.append(face)
  574.             continue
  575.         
  576.         #Check whether or not to make protrusions
  577.         if makeprots == 0:
  578.             face = Face([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]])
  579.             if thereAreMats == 1:
  580.                 face.materialIndex = currmat
  581.             newmesh.faces.append(face)
  582.             if makedoodads == 1 and onlyonprotrusions == 0:
  583.                 if doodonselectedfaces == 1:
  584.                     if currface.sel:
  585.                         tempmesh = NMesh.GetRaw()
  586.                         tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  587.                         newmesh.verts.extend(tempmesh.verts)
  588.                         newmesh.faces.extend(tempmesh.faces)
  589.                 else:
  590.                     tempmesh = NMesh.GetRaw()
  591.                     tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  592.                     newmesh.verts.extend(tempmesh.verts)
  593.                     newmesh.faces.extend(tempmesh.faces)
  594.             continue
  595.         
  596.         #Check if only changing selected faces
  597.         if useselectedfaces == 1:
  598.             #check if currface is selected
  599.             if currface.sel:
  600.                 a = 1
  601.             else:
  602.                 face = Face([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]])
  603.                 if thereAreMats == 1:
  604.                     face.materialIndex = currmat
  605.                 newmesh.faces.append(face)
  606.                 if makedoodads == 1 and onlyonprotrusions == 0:
  607.                     if doodonselectedfaces != 1:
  608.                         tempmesh = NMesh.GetRaw()
  609.                         tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  610.                         newmesh.verts.extend(tempmesh.verts)
  611.                         newmesh.faces.extend(tempmesh.faces)
  612.                 continue
  613.         #Check if face should be modified by random chance
  614.         if randnum(0,1)>faceschangedpercent: 
  615.             face = Face([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]])
  616.             if thereAreMats == 1:
  617.                 face.materialIndex = currmat
  618.             newmesh.faces.append(face)
  619.             if makedoodads == 1 and onlyonprotrusions == 0:
  620.                 if doodonselectedfaces == 1:
  621.                     if currface.sel:
  622.                         tempmesh = NMesh.GetRaw()
  623.                         tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  624.                         newmesh.verts.extend(tempmesh.verts)
  625.                         newmesh.faces.extend(tempmesh.faces)
  626.                 else:
  627.                     tempmesh = NMesh.GetRaw()
  628.                     tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  629.                     newmesh.verts.extend(tempmesh.verts)
  630.                     newmesh.faces.extend(tempmesh.faces)
  631.             continue
  632.         
  633.         center = Vector([0,0,0])
  634.         for pt in currface.v:
  635.             center = center + pt.co
  636.         center = center / len(currface.v)
  637.         
  638.         #Determine amount of subfaces
  639.         subfaces = round(randnum(1,len(subfaceArray)),0)
  640.         subfaces = subfaceArray[(int(subfaces) - 1)]
  641.         
  642.         ######################## START DEALING WITH PROTRUSIONS #####################
  643.         
  644.         if subfaces == 1:
  645.             prot = randnum(minimumheight,maximumheight)
  646.             tempface = extrude(center,currface.no,prot,currface.v[0].index,currface.v[1].index,currface.v[2].index,currface.v[3].index,selectface1)
  647.             if makedoodads == 1:
  648.                 if doodonselectedfaces == 1:
  649.                     if currface.sel:
  650.                         tempmesh = NMesh.GetRaw()
  651.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  652.                         newmesh.verts.extend(tempmesh.verts)
  653.                         newmesh.faces.extend(tempmesh.faces)
  654.                 else:
  655.                     tempmesh = NMesh.GetRaw()
  656.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  657.                     newmesh.verts.extend(tempmesh.verts)
  658.                     newmesh.faces.extend(tempmesh.faces)
  659.         
  660.         elif subfaces == 2:
  661.             orientation = int(round(randnum(0,1)))
  662.             p1 = currface.v[orientation]
  663.             p2 = currface.v[orientation + 1]
  664.             p3 = ((p2.co - p1.co)/2) + p1.co
  665.             ve1 = Vert(p3[0],p3[1],p3[2])
  666.             ve1.sel = 0
  667.             p1 = currface.v[2 + orientation]
  668.             if orientation < 0.5:
  669.                 p2 = currface.v[3]
  670.             else:
  671.                 p2 = currface.v[0]
  672.             p3 = ((p2.co - p1.co)/2) + p1.co
  673.             ve2 = Vert(p3[0],p3[1],p3[2])
  674.             ve2.sel = 0
  675.             if orientation < 0.5:
  676.                 verti = currface.v[3]
  677.                 p3 = verti.index
  678.                 v1 = p3
  679.                 verti = currface.v[0]
  680.                 p0 = verti.index
  681.                 v2 = p0
  682.             else:
  683.                 verti = currface.v[0]
  684.                 p0 = verti.index
  685.                 v1 = p0
  686.                 verti = currface.v[1]
  687.                 p1 = verti.index
  688.                 v2 = p1
  689.             newmesh.verts.append(ve1)
  690.             newmesh.verts.append(ve2)
  691.             index = len(newmesh.verts) - 2
  692.             v4 = index + 1
  693.             v3 = index
  694.             center = Vector([0, 0, 0])
  695.             for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]:
  696.                 center += pt.co
  697.             center = center/4
  698.             prot = randnum(minimumheight,maximumheight)
  699.             tempface = extrude(center,currface.no,prot,v1,v2,v3,v4,selectface2)
  700.             if makedoodads == 1:
  701.                 if doodonselectedfaces == 1:
  702.                     if currface.sel:
  703.                         tempmesh = NMesh.GetRaw()
  704.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  705.                         newmesh.verts.extend(tempmesh.verts)
  706.                         newmesh.faces.extend(tempmesh.faces)
  707.                 else:
  708.                     tempmesh = NMesh.GetRaw()
  709.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  710.                     newmesh.verts.extend(tempmesh.verts)
  711.                     newmesh.faces.extend(tempmesh.faces)
  712.             if orientation < 0.5:
  713.                 verti = currface.v[1]
  714.                 p1 = verti.index
  715.                 v1 = p1
  716.                 verti = currface.v[2]
  717.                 p2 = verti.index
  718.                 v2 = p2
  719.             else:
  720.                 verti = currface.v[2]
  721.                 p2 = verti.index
  722.                 v1 = p2
  723.                 verti = currface.v[3]
  724.                 p3 = verti.index
  725.                 v2 = p3
  726.             center = Vector([0]*3)
  727.             for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]:
  728.                 center += pt.co
  729.             center = center/4
  730.             prot = randnum(minimumheight,maximumheight)
  731.             tempface = extrude(center,currface.no,prot,v1,v2,v4,v3,selectface2)
  732.             if makedoodads == 1:
  733.                 if doodonselectedfaces == 1:
  734.                     if currface.sel:
  735.                         tempmesh = NMesh.GetRaw()
  736.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  737.                         newmesh.verts.extend(tempmesh.verts)
  738.                         newmesh.faces.extend(tempmesh.faces)
  739.                 else:
  740.                     tempmesh = NMesh.GetRaw()
  741.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  742.                     newmesh.verts.extend(tempmesh.verts)
  743.                     newmesh.faces.extend(tempmesh.faces)
  744.             if orientation < 0.5:
  745.                 face = Face([newmesh.verts[p0],newmesh.verts[p1],newmesh.verts[v3]])
  746.                 if thereAreMats == 1:
  747.                     if reassignMats == 0 or protSideMat == 0:
  748.                         face.materialIndex = currmat
  749.                     else:
  750.                         face.materialIndex = protSideMat-1
  751.                 newmesh.faces.append(face)
  752.                 face = Face([newmesh.verts[p2],newmesh.verts[p3],newmesh.verts[v4]])
  753.                 if thereAreMats == 1:
  754.                     if reassignMats == 0 or protSideMat == 0:
  755.                         face.materialIndex = currmat
  756.                     else:
  757.                         face.materialIndex = protSideMat-1
  758.                 newmesh.faces.append(face)
  759.             else:
  760.                 face = Face([newmesh.verts[p1],newmesh.verts[p2],newmesh.verts[v3]])
  761.                 if thereAreMats == 1:
  762.                     if reassignMats == 0 or protSideMat == 0:
  763.                         face.materialIndex = currmat
  764.                     else:
  765.                         face.materialIndex = protSideMat-1
  766.                 newmesh.faces.append(face)
  767.                 face = Face([newmesh.verts[p3],newmesh.verts[p0],newmesh.verts[v4]])
  768.                 if thereAreMats == 1:
  769.                     if reassignMats == 0 or protSideMat == 0:
  770.                         face.materialIndex = currmat
  771.                     else:
  772.                         face.materialIndex = protSideMat-1
  773.                 newmesh.faces.append(face)
  774.             
  775.         elif subfaces == 3:
  776.             layer2inds = []
  777.             layer2verts = []
  778.             orientation = int(round(randnum(0,1)))
  779.             rotation = int(round(randnum(0,1)))
  780.             p1 = currface.v[orientation]
  781.             p2 = currface.v[orientation + 1]
  782.             p3 = ((p2.co - p1.co)/2) + p1.co
  783.             ve1 = Vert(p3[0],p3[1],p3[2])
  784.             ve1.sel = 0
  785.             p1 = currface.v[2 + orientation]
  786.             if orientation < 0.5:
  787.                 p2 = currface.v[3]
  788.             else:
  789.                 p2 = currface.v[0]
  790.             p3 = ((p2.co - p1.co)/2) + p1.co
  791.             ve2 = Vert(p3[0],p3[1],p3[2])
  792.             ve2.sel = 0
  793.             fp = []
  794.     
  795.             #make first protrusion
  796.             if rotation < 0.5:
  797.                 if orientation < 0.5:
  798.                     verti = currface.v[3]
  799.                     fp.append(verti.index)
  800.                     v1 = verti.index
  801.                     verti = currface.v[0]
  802.                     fp.append(verti.index)
  803.                     v2 = verti.index
  804.                     layer2verts.extend([newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index]])
  805.                 else:
  806.                     verti = currface.v[0]
  807.                     fp.append(verti.index)
  808.                     v1 = verti.index
  809.                     verti = currface.v[1]
  810.                     fp.append(verti.index)
  811.                     v2 = verti.index
  812.                     layer2verts.extend([newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]])
  813.                 newmesh.verts.append(ve1)
  814.                 newmesh.verts.append(ve2)
  815.                 index = len(newmesh.verts) - 2
  816.                 v4 = index + 1
  817.                 v3 = index
  818.                 center = Vector([0]*3)
  819.                 for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]:
  820.                     center += pt.co
  821.                 center = center/4
  822.                 prot = randnum(minimumheight,maximumheight)
  823.                 layer2inds.extend([v3,v4])
  824.                 tempface = extrude(center,currface.no,prot,v1,v2,v3,v4,selectface3)
  825.                 if makedoodads == 1:
  826.                     if doodonselectedfaces == 1:
  827.                         if currface.sel:
  828.                             tempmesh = NMesh.GetRaw()
  829.                             tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  830.                             newmesh.verts.extend(tempmesh.verts)
  831.                             newmesh.faces.extend(tempmesh.faces)
  832.                     else:
  833.                         tempmesh = NMesh.GetRaw()
  834.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  835.                         newmesh.verts.extend(tempmesh.verts)
  836.                         newmesh.faces.extend(tempmesh.faces)
  837.             #Still first protrusion
  838.             else:
  839.                 if orientation < 0.5:
  840.                     verti = currface.v[1]
  841.                     fp.append(verti.index)
  842.                     v1 = verti.index
  843.                     verti = currface.v[2]
  844.                     fp.append(verti.index)
  845.                     v2 = verti.index
  846.                     layer2verts.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[3].index]])
  847.                 else:
  848.                     verti = currface.v[2]
  849.                     fp.append(verti.index)
  850.                     v1 = verti.index
  851.                     verti = currface.v[3]
  852.                     fp.append(verti.index)
  853.                     v2 = verti.index
  854.                     layer2verts.extend([newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[0].index]])
  855.                 newmesh.verts.append(ve2)
  856.                 newmesh.verts.append(ve1)
  857.                 index = len(newmesh.verts) - 2
  858.                 v4 = index
  859.                 v3 = index + 1
  860.                 center = Vector([0]*3)
  861.                 for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]:
  862.                     center += pt.co
  863.                 center = center/4
  864.                 prot = randnum(minimumheight,maximumheight)
  865.                 layer2inds.extend([index, index +1])
  866.                 tempface = extrude(center,currface.no,prot,v1,v2,v4,v3,selectface3)
  867.                 if makedoodads == 1:
  868.                     if doodonselectedfaces == 1:
  869.                         if currface.sel:
  870.                             tempmesh = NMesh.GetRaw()
  871.                             tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  872.                             newmesh.verts.extend(tempmesh.verts)
  873.                             newmesh.faces.extend(tempmesh.faces)
  874.                     else:
  875.                         tempmesh = NMesh.GetRaw()
  876.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  877.                         newmesh.verts.extend(tempmesh.verts)
  878.                         newmesh.faces.extend(tempmesh.faces)
  879.             
  880.             #split next rect(pre-arranged, no orientation crud)--make flag in extruder for only one existing vert in mesh
  881.             p1 = newmesh.verts[layer2inds[0]]
  882.             p2 = newmesh.verts[layer2inds[1]]
  883.             p3 = ((p2.co - p1.co)/2) + p1.co
  884.             ve3 = Vert(p3[0],p3[1],p3[2])
  885.             ve3.sel = 0
  886.             p1 = layer2verts[0]
  887.             p2 = layer2verts[1]
  888.             p3 = ((p2.co - p1.co)/2) + p1.co
  889.             ve4 = Vert(p3[0],p3[1],p3[2])
  890.             ve4.sel = 0
  891.             newmesh.verts.append(ve3)
  892.             newmesh.verts.append(ve4)
  893.             tempindex = len(newmesh.verts) - 2
  894.             v5 = tempindex
  895.             v6 = tempindex + 1
  896.             verti = layer2verts[0]
  897.             t0 = verti.index
  898.             center = Vector([0]*3)
  899.             for pt in [newmesh.verts[v5],newmesh.verts[v6],newmesh.verts[t0],newmesh.verts[v3]]:
  900.                 center += pt.co
  901.             center = center/4
  902.             prot = randnum(minimumheight,maximumheight)
  903.             if rotation < 0.5: flino = 1
  904.             else: flino = 0
  905.             tempface = extrude(center,currface.no,prot,v3,v5,v6,t0,selectface3,flino)
  906.             if makedoodads == 1:
  907.                 if doodonselectedfaces == 1:
  908.                     if currface.sel:
  909.                         tempmesh = NMesh.GetRaw()
  910.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  911.                         newmesh.verts.extend(tempmesh.verts)
  912.                         newmesh.faces.extend(tempmesh.faces)
  913.                     tempmesh = NMesh.GetRaw()
  914.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  915.                     newmesh.verts.extend(tempmesh.verts)
  916.                     newmesh.faces.extend(tempmesh.faces)
  917.             if rotation < 0.5:
  918.                 fpt = t0
  919.                 face = Face([newmesh.verts[fp[1]],newmesh.verts[fpt],newmesh.verts[v3]])
  920.                 if thereAreMats == 1:
  921.                     if reassignMats == 0 or protSideMat == 0:
  922.                         face.materialIndex = currmat
  923.                     else:
  924.                         face.materialIndex = protSideMat-1
  925.                 newmesh.faces.append(face)
  926.             else:
  927.                 fpt = t0
  928.                 face = Face([newmesh.verts[fp[0]],newmesh.verts[v3],newmesh.verts[fpt]])
  929.                 if thereAreMats == 1:
  930.                     if reassignMats == 0 or protSideMat == 0:
  931.                         face.materialIndex = currmat
  932.                     else:
  933.                         face.materialIndex = protSideMat-1
  934.                 newmesh.faces.append(face)
  935.             verti = layer2verts[1]
  936.             tempindex = verti.index
  937.             center = Vector([0]*3)
  938.             for pt in [newmesh.verts[v5],newmesh.verts[v6],newmesh.verts[tempindex],newmesh.verts[v4]]:
  939.                 center += pt.co
  940.             center = center/4
  941.             prot = randnum(minimumheight,maximumheight)
  942.             tempface = extrude(center,currface.no,prot,v6,v5,v4,tempindex,selectface3,flino)
  943.             if makedoodads == 1:
  944.                 if doodonselectedfaces == 1:
  945.                     if currface.sel:
  946.                         tempmesh = NMesh.GetRaw()
  947.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  948.                         newmesh.verts.extend(tempmesh.verts)
  949.                         newmesh.faces.extend(tempmesh.faces)
  950.                 else:
  951.                     tempmesh = NMesh.GetRaw()
  952.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  953.                     newmesh.verts.extend(tempmesh.verts)
  954.                     newmesh.faces.extend(tempmesh.faces)
  955.             if rotation < 0.5:
  956.                 face = Face([newmesh.verts[tempindex],newmesh.verts[fp[0]],newmesh.verts[v4]])
  957.                 if thereAreMats == 1:
  958.                     if reassignMats == 0 or protSideMat == 0:
  959.                         face.materialIndex = currmat
  960.                     else:
  961.                         face.materialIndex = protSideMat-1
  962.                 newmesh.faces.append(face)
  963.                 face = Face([newmesh.verts[fpt],newmesh.verts[tempindex],newmesh.verts[v6]])
  964.                 if thereAreMats == 1:
  965.                     if reassignMats == 0 or protSideMat == 0:
  966.                         face.materialIndex = currmat
  967.                     else:
  968.                         face.materialIndex = protSideMat-1
  969.                 newmesh.faces.append(face)
  970.             else:
  971.                 face = Face([newmesh.verts[tempindex],newmesh.verts[v4],newmesh.verts[fp[1]]])
  972.                 if thereAreMats == 1:
  973.                     if reassignMats == 0 or protSideMat == 0:
  974.                         face.materialIndex = currmat
  975.                     else:
  976.                         face.materialIndex = protSideMat-1
  977.                 newmesh.faces.append(face)
  978.                 face = Face([newmesh.verts[tempindex],newmesh.verts[fpt],newmesh.verts[v6]])
  979.                 if thereAreMats == 1:
  980.                     if reassignMats == 0 or protSideMat == 0:
  981.                         face.materialIndex = currmat
  982.                     else:
  983.                         face.materialIndex = protSideMat-1
  984.                 newmesh.faces.append(face)
  985.             
  986.         else:
  987.             #get all points
  988.             verti = currface.v[0]
  989.             p0 = verti.index
  990.             
  991.             verti = currface.v[1]
  992.             p1 = verti.index
  993.         
  994.             pt = ((newmesh.verts[p1].co - newmesh.verts[p0].co)/2) + newmesh.verts[p0].co
  995.             v1 = Vert(pt[0],pt[1],pt[2])
  996.             v1.sel = 0
  997.     
  998.             verti = currface.v[2]
  999.             p2 = verti.index
  1000.  
  1001.             pt =  ((newmesh.verts[p2].co - newmesh.verts[p1].co)/2) + newmesh.verts[p1].co
  1002.             v2 = Vert(pt[0],pt[1],pt[2])
  1003.             v2.sel = 0
  1004.  
  1005.             verti = currface.v[3]
  1006.             p3 = verti.index
  1007.  
  1008.             pt =  ((newmesh.verts[p3].co - newmesh.verts[p2].co)/2) + newmesh.verts[p2].co
  1009.             v3 = Vert(pt[0],pt[1],pt[2])
  1010.             v3.sel = 0
  1011.  
  1012.             pt =  ((newmesh.verts[p0].co - newmesh.verts[p3].co)/2) + newmesh.verts[p3].co
  1013.             v4 = Vert(pt[0],pt[1],pt[2])
  1014.             v4.sel = 0
  1015.  
  1016.             pt =  ((v3.co - v1.co)/2) + v1.co
  1017.             m = Vert(pt[0],pt[1],pt[2])
  1018.             m.sel = 0
  1019.             
  1020.             #extrusion 1
  1021.             newmesh.verts.extend([v1,m,v4])
  1022.             index = len(newmesh.verts) - 3
  1023.             v1 = index
  1024.             m = index + 1
  1025.             v4 = index + 2
  1026.             center = Vector([0]*3)
  1027.             for pt in [newmesh.verts[p0],newmesh.verts[v1],newmesh.verts[m],newmesh.verts[v4]]:
  1028.                 center += pt.co
  1029.             center = center/4
  1030.             prot = randnum(minimumheight,maximumheight)
  1031.             tempface = extrude(center,currface.no,prot,p0,v1,m,v4,selectface4)
  1032.             if makedoodads == 1:
  1033.                 if doodonselectedfaces == 1:
  1034.                     if currface.sel:
  1035.                         tempmesh = NMesh.GetRaw()
  1036.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1037.                         newmesh.verts.extend(tempmesh.verts)
  1038.                         newmesh.faces.extend(tempmesh.faces)
  1039.                 else:
  1040.                     tempmesh = NMesh.GetRaw()
  1041.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1042.                     newmesh.verts.extend(tempmesh.verts)
  1043.                     newmesh.faces.extend(tempmesh.faces)
  1044.             
  1045.             #extrusion 2
  1046.             newmesh.verts.extend([v2])
  1047.             index = len(newmesh.verts) - 1
  1048.             v2 = index
  1049.             center = Vector([0]*3)
  1050.             for pt in [newmesh.verts[m],newmesh.verts[v1],newmesh.verts[p1],newmesh.verts[v2]]:
  1051.                 center += pt.co
  1052.             center = center/4
  1053.             prot = randnum(minimumheight,maximumheight)
  1054.             tempface = extrude(center,currface.no,prot,m,v1,p1,v2,selectface4)
  1055.             if makedoodads == 1:
  1056.                 if doodonselectedfaces == 1:
  1057.                     if currface.sel:
  1058.                         tempmesh = NMesh.GetRaw()
  1059.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1060.                         newmesh.verts.extend(tempmesh.verts)
  1061.                         newmesh.faces.extend(tempmesh.faces)
  1062.                 else:
  1063.                     tempmesh = NMesh.GetRaw()
  1064.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1065.                     newmesh.verts.extend(tempmesh.verts)
  1066.                     newmesh.faces.extend(tempmesh.faces)
  1067.             
  1068.             #extrusion 3
  1069.             newmesh.verts.extend([v3])
  1070.             index = len(newmesh.verts) - 1
  1071.             v3 = index
  1072.             center = Vector([0]*3)
  1073.             for pt in [newmesh.verts[m],newmesh.verts[v2],newmesh.verts[p2],newmesh.verts[v3]]:
  1074.                 center += pt.co
  1075.             center = center/4
  1076.             prot = randnum(minimumheight,maximumheight)
  1077.             tempface = extrude(center,currface.no,prot,m,v2,p2,v3,selectface4)
  1078.             if makedoodads == 1:
  1079.                 if doodonselectedfaces == 1:
  1080.                     if currface.sel:
  1081.                         tempmesh = NMesh.GetRaw()
  1082.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1083.                         newmesh.verts.extend(tempmesh.verts)
  1084.                         newmesh.faces.extend(tempmesh.faces)
  1085.                 else:
  1086.                     tempmesh = NMesh.GetRaw()
  1087.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1088.                     newmesh.verts.extend(tempmesh.verts)
  1089.                     newmesh.faces.extend(tempmesh.faces)
  1090.             
  1091.             #extrusion 4
  1092.             center = Vector([0]*3)
  1093.             for pt in [newmesh.verts[m],newmesh.verts[v3],newmesh.verts[p3],newmesh.verts[v4]]:
  1094.                 center += pt.co
  1095.             center = center/4
  1096.             prot = randnum(minimumheight,maximumheight)
  1097.             tempface = extrude(center,currface.no,prot,v4,m,v3,p3,selectface4)
  1098.             if makedoodads == 1:
  1099.                 if doodonselectedfaces == 1:
  1100.                     if currface.sel:
  1101.                         tempmesh = NMesh.GetRaw()
  1102.                         tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1103.                         newmesh.verts.extend(tempmesh.verts)
  1104.                         newmesh.faces.extend(tempmesh.faces)
  1105.                 else:
  1106.                     tempmesh = NMesh.GetRaw()
  1107.                     tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent)
  1108.                     newmesh.verts.extend(tempmesh.verts)
  1109.                     newmesh.faces.extend(tempmesh.faces)
  1110.             
  1111.             face = Face([newmesh.verts[p0],newmesh.verts[p1],newmesh.verts[v1]])
  1112.             if thereAreMats == 1:
  1113.                 if reassignMats == 0 or protSideMat == 0:
  1114.                     face.materialIndex = currmat
  1115.                 else:
  1116.                     face.materialIndex = protSideMat-1
  1117.             newmesh.faces.append(face)
  1118.             face = Face([newmesh.verts[p1],newmesh.verts[p2],newmesh.verts[v2]])
  1119.             if thereAreMats == 1:
  1120.                 if reassignMats == 0 or protSideMat == 0:
  1121.                     face.materialIndex = currmat
  1122.                 else:
  1123.                     face.materialIndex = protSideMat-1
  1124.             newmesh.faces.append(face)
  1125.             face = Face([newmesh.verts[p2],newmesh.verts[p3],newmesh.verts[v3]])
  1126.             if thereAreMats == 1:
  1127.                 if reassignMats == 0 or protSideMat == 0:
  1128.                     face.materialIndex = currmat
  1129.                 else:
  1130.                     face.materialIndex = protSideMat-1
  1131.             newmesh.faces.append(face)
  1132.             face = Face([newmesh.verts[p3],newmesh.verts[p0],newmesh.verts[v4]])
  1133.             if thereAreMats == 1:
  1134.                 if reassignMats == 0 or protSideMat == 0:
  1135.                     face.materialIndex = currmat
  1136.                 else:
  1137.                     face.materialIndex = protSideMat-1
  1138.             newmesh.faces.append(face)
  1139.             
  1140.     #NMesh.PutRaw(newmesh)
  1141.     if deselface == 1:
  1142.         for unvert in origmesh.verts:
  1143.             newmesh.verts[unvert.index].sel = 0
  1144.     if makenewobj == 1:
  1145.         newobj = origobj.__copy__()
  1146.         newobj.link(newmesh)
  1147.         scene = Blender.Scene.GetCurrent()
  1148.         scene.objects.link(newobj)
  1149.         origobj.sel = 0
  1150.     else:
  1151.         origobj.link(newmesh)
  1152.     
  1153.     #Return to Editmode if previously in it
  1154.     if editmode: Window.EditMode(1)
  1155.  
  1156. ####################### gui ######################
  1157. from Blender.BGL import *
  1158. from Blender.Draw import *
  1159.  
  1160. def ErrorText(errortext):
  1161.     Window.WaitCursor(0)
  1162.     Text(errortext)
  1163.     PupMenu("ERROR: %s" % errortext.lower())
  1164.  
  1165. #Global Buttons
  1166. makenewobject = Create(makenewobj)
  1167. messagetext = Create(errortext)
  1168.  
  1169. #Protrusion Buttons
  1170. doprots = Create(makeprots)
  1171. facechange = Create(faceschangedpercent*100)
  1172. minheight = Create(minimumheight)
  1173. maxheight = Create(maximumheight)
  1174. sub1 = Create(subface1)
  1175. sub2 = Create(subface2)
  1176. sub3 = Create(subface3)
  1177. sub4 = Create(subface4)
  1178. mintaper = Create(minimumtaperpercent*100)
  1179. maxtaper = Create(maximumtaperpercent*100)
  1180. useselected = Create(useselectedfaces)
  1181. selface1 = Create(selectface1)
  1182. selface2 = Create(selectface2)
  1183. selface3 = Create(selectface3)
  1184. selface4 = Create(selectface4)
  1185. deselectvertices = Create(deselface)
  1186. #selectbyverts = Create(vertselected)
  1187.  
  1188. #Doodad Buttons
  1189. dodoodads = Create(makedoodads)
  1190. doodadfacechange = Create(doodadfacepercent*100)
  1191. seldoodad = Create(selectdoodad)
  1192. onprot = Create(onlyonprotrusions)
  1193. dood1 = Create(doodad1)
  1194. dood2 = Create(doodad2)
  1195. dood3 = Create(doodad3)
  1196. dood4 = Create(doodad4)
  1197. dood5 = Create(doodad5)
  1198. dood6 = Create(doodad6)
  1199. doodadminamount = Create(doodadminperface)
  1200. doodadmaxamount = Create(doodadmaxperface)
  1201. doodsizemin = Create(doodadminsize*100)
  1202. doodsizemax = Create(doodadmaxsize*100)
  1203. doodheightmin = Create(doodadminheight)
  1204. doodheightmax = Create(doodadmaxheight)
  1205. doodonselface = Create(doodonselectedfaces)
  1206. seldoodtop = Create(selectdoodadtoponly)
  1207.  
  1208. #Material Buttons
  1209. assignNewMats = Create(reassignMats)
  1210. replProtSideIndex = Create(protSideMat)
  1211. replProtTopIndex = Create(protTopMat)
  1212. replDoodSideIndex = Create(doodSideMat)
  1213. replDoodTopIndex = Create(doodTopMat)
  1214.  
  1215. # Events
  1216. EVENT_NONE = 1
  1217. EVENT_DISCOMBOBULATE = 2
  1218. EVENT_EXIT = 3
  1219.  
  1220. # Additions for moving gui
  1221. hadd = 0
  1222. wadd = 0
  1223. thadd = 410
  1224. phadd = 245
  1225. pwadd = 0
  1226. dhadd = 55
  1227. dwadd = 0
  1228. ghadd = 10
  1229. gwadd = 0
  1230. mhadd = 55
  1231. mwadd = 312
  1232.  
  1233. def colorbox(x,y,xright,bottom):
  1234.    glColor3f(0.75, 0.75, 0.75)
  1235.    glRecti(x + 1, y + 1, xright - 1, bottom - 1)
  1236.  
  1237. firstDraw = 1
  1238.  
  1239. def draw():
  1240.     
  1241.     #Protrusions
  1242.     global doprots
  1243.     global facechange
  1244.     global minheight
  1245.     global maxheight
  1246.     global sub1
  1247.     global sub2
  1248.     global sub3
  1249.     global sub4
  1250.     global mintaper
  1251.     global maxtaper
  1252.     global useselected
  1253.     global selface1
  1254.     global selface2
  1255.     global selface3
  1256.     global selface4
  1257.     global deselectvertices
  1258.     #global selectbyverts
  1259.     
  1260.     #Doodads
  1261.     global dodoodads
  1262.     global doodadfacechange
  1263.     global seldoodad
  1264.     global onprot
  1265.     global dood1
  1266.     global dood2
  1267.     global dood3
  1268.     global dood4
  1269.     global dood5
  1270.     global dood6
  1271.     global doodadminamount
  1272.     global doodadmaxamount
  1273.     global doodsizemin
  1274.     global doodsizemax
  1275.     global doodheightmin
  1276.     global doodheightmax
  1277.     global doodonselface
  1278.     global seldoodtop
  1279.     
  1280.     #Materials
  1281.     global assignNewMats
  1282.     global replProtSideIndex
  1283.     global replProtTopIndex
  1284.     global replDoodSideIndex
  1285.     global replDoodTopIndex
  1286.     
  1287.     #Global Settings
  1288.     global makenewobject
  1289.     global messagetext
  1290.     global errortext
  1291.     global EVENT_NONE,EVENT_DRAW,EVENT_EXIT,EVENT_UP,EVENT_DOWN,EVENT_LEFT,EVENT_RIGHT
  1292.     
  1293.     # Additions for moving gui
  1294.     global hadd
  1295.     global wadd
  1296.     global thadd
  1297.     global phadd
  1298.     global pwadd
  1299.     global dhadd
  1300.     global dwadd
  1301.     global ghadd
  1302.     global gwadd
  1303.     global mhadd
  1304.     global mwadd
  1305.     
  1306.     #This is for creating the initial layout
  1307.     global firstDraw
  1308.     if(firstDraw == 1):
  1309.         if(((Window.GetAreaSize()[1])*1.7) < Window.GetAreaSize()[0]):
  1310.             thadd = 180
  1311.             phadd = 10
  1312.             dhadd = 10
  1313.             mhadd = 55
  1314.             ghadd = 10
  1315.             pwadd = 0
  1316.             dwadd = 305
  1317.             mwadd = 610
  1318.             gwadd = 610
  1319.         else:
  1320.             thadd = 505
  1321.             phadd = 346
  1322.             dhadd = 160
  1323.             mhadd = 56
  1324.             ghadd = 10
  1325.             pwadd = 0
  1326.             dwadd = 0
  1327.             mwadd = 0
  1328.             gwadd = 0
  1329.         firstDraw = 0
  1330.     
  1331.     
  1332.     #Title :420high
  1333.     glClearColor(0.6, 0.6, 0.6, 1.0)
  1334.     glClear(GL_COLOR_BUFFER_BIT)
  1335.     glColor3f(0.0,0.0,0.0)
  1336.     glRasterPos2d(8+wadd, thadd+hadd)
  1337.     Text("Discombobulator v2.1b")
  1338.     
  1339.     #Protrusion
  1340.     colorbox(8+pwadd+wadd,150+phadd+hadd,312+pwadd+wadd,phadd-5+hadd)
  1341.     glColor3f(0.0,0.0,0.0)
  1342.     glRasterPos2d(12+pwadd+wadd, 140+phadd+hadd)
  1343.     Text("Protrusions:")
  1344.     doprots = Toggle("Make Protrusions",EVENT_NONE,12+pwadd+wadd,117+phadd+hadd,145,18,doprots.val,"Make Protrusions?")
  1345.     facechange = Number("Face %: ",EVENT_NONE,162+pwadd+wadd,117+phadd+hadd,145,18,facechange.val,0,100,"Percentage of faces that will grow protrusions")
  1346.     useselected = Toggle("Only selected faces",EVENT_NONE,12+pwadd+wadd,97+phadd+hadd,145,18,useselected.val,"If on, only selected faces will be modified")
  1347.     deselectvertices = Toggle("Deselect Selected",EVENT_NONE,162+pwadd+wadd,97+phadd+hadd,145,18,deselectvertices.val,"Deselects any selected vertex except for ones selected by \"Select Tops\"")
  1348.     
  1349.     #Protrusion properties
  1350.     glColor3f(0.0,0.0,0.0)
  1351.     glRasterPos2d(12+pwadd+wadd, 80+phadd+hadd)
  1352.     Text("Protrusion Properties:")
  1353.     BeginAlign()
  1354.     minheight = Number("Min Height: ",EVENT_NONE,12+pwadd+wadd,57+phadd+hadd,145,18,minheight.val,-100.0,100.0,"Minimum height of any protrusion")
  1355.     maxheight = Number("Max Height: ",EVENT_NONE,162+pwadd+wadd,57+phadd+hadd,145,18,maxheight.val,-100.0,100.0,"Maximum height of any protrusion")
  1356.     EndAlign()
  1357.     BeginAlign()
  1358.     mintaper = Number("Min Taper %: ",EVENT_NONE,12+pwadd+wadd,37+phadd+hadd,145,18,mintaper.val,0,100,"Minimum taper percentage of protrusion")
  1359.     maxtaper = Number("Max Taper %: ",EVENT_NONE,162+pwadd+wadd,37+phadd+hadd,145,18,maxtaper.val,0,100,"Maximum taper percentage of protrusion")
  1360.     EndAlign()
  1361.     glRasterPos2d(19+pwadd+wadd, 22+phadd+hadd)
  1362.     Text("Number of protrusions:")
  1363.     BeginAlign()
  1364.     sub1 = Toggle("1",EVENT_NONE,12+pwadd+wadd,phadd+hadd,34,18,sub1.val,"One Protrusion")
  1365.     sub2 = Toggle("2",EVENT_NONE,48+pwadd+wadd,phadd+hadd,34,18,sub2.val,"Two Protrusions")
  1366.     sub3 = Toggle("3",EVENT_NONE,84+pwadd+wadd,phadd+hadd,34,18,sub3.val,"Three Protrusions")
  1367.     sub4 = Toggle("4",EVENT_NONE,120+pwadd+wadd,phadd+hadd,34,18,sub4.val,"Four Protrusions")
  1368.     EndAlign()
  1369.     glRasterPos2d(195+pwadd+wadd, 22+phadd+hadd)
  1370.     Text("Select tops of:")
  1371.     BeginAlign()
  1372.     selface1 = Toggle("1",EVENT_NONE,165+pwadd+wadd,phadd+hadd,34,18,selface1.val,"Select the tip of the protrusion when it is created")
  1373.     selface2 = Toggle("2",EVENT_NONE,201+pwadd+wadd,phadd+hadd,34,18,selface2.val,"Select the tips of each protrusion when they are created")
  1374.     selface3 = Toggle("3",EVENT_NONE,237+pwadd+wadd,phadd+hadd,34,18,selface3.val,"Select the tips of each protrusion when they are created")
  1375.     selface4 = Toggle("4",EVENT_NONE,273+pwadd+wadd,phadd+hadd,34,18,selface4.val,"Select the tips of each protrusion when they are created")
  1376.     EndAlign()
  1377.     #Doodads
  1378.     colorbox(8+dwadd+wadd,175+dhadd+hadd,312+dwadd+wadd,dhadd-5+hadd)
  1379.     glColor3f(0.0,0.0,0.0)
  1380.     glRasterPos2d(12+dwadd+wadd, 165+dhadd+hadd)
  1381.     Text("Doodads:")
  1382.     BeginAlign()
  1383.     dood1 = Toggle("1 Box",EVENT_NONE,12+dwadd+wadd,142+dhadd+hadd,45,18,dood1.val,"Creates a rectangular box")
  1384.     dood2 = Toggle("2 Box",EVENT_NONE,61+dwadd+wadd,142+dhadd+hadd,45,18,dood2.val,"Creates 2 side-by-side rectangular boxes")
  1385.     dood3 = Toggle("3 Box",EVENT_NONE,110+dwadd+wadd,142+dhadd+hadd,45,18,dood3.val,"Creates 3 side-by-side rectangular boxes")
  1386.     EndAlign()
  1387.     BeginAlign()
  1388.     dood4 = Toggle("\"L\"",EVENT_NONE,164+dwadd+wadd,142+dhadd+hadd,45,18,dood4.val,"Creates a Tetris-style \"L\" shape")
  1389.     dood5 = Toggle("\"T\"",EVENT_NONE,213+dwadd+wadd,142+dhadd+hadd,45,18,dood5.val,"Creates a Tetris-style \"T\" shape")
  1390.     dood6 = Toggle("\"S\"",EVENT_NONE,262+dwadd+wadd,142+dhadd+hadd,45,18,dood6.val,"Creates a sort-of \"S\" or \"Z\" shape")
  1391.     EndAlign()
  1392.     dodoodads = Toggle("Make Doodads",EVENT_NONE,12+dwadd+wadd,120+dhadd+hadd,145,18,dodoodads.val,"Make Doodads?")
  1393.     doodadfacechange = Number("Face %: ",EVENT_NONE,162+dwadd+wadd,120+dhadd+hadd,145,18,doodadfacechange.val,0,100,"Percentage of faces that will gain doodads")
  1394.     seldoodad = Toggle("Select Doodads",EVENT_NONE,12+dwadd+wadd,100+dhadd+hadd,145,18,seldoodad.val,"Selects doodads when they are created")
  1395.     seldoodtop = Toggle("Only Select Tops",EVENT_NONE,162+dwadd+wadd,100+dhadd+hadd,145,18,seldoodtop.val,"Only Selects tops of doodads when\"Select Doodads\" is on")
  1396.     doodonselface = Toggle("Only selected faces",EVENT_NONE,12+dwadd+wadd,80+dhadd+hadd,145,18,doodonselface.val,"Only create doodads on selected faces")
  1397.     onprot = Toggle("Only on Protrusions",EVENT_NONE,162+dwadd+wadd,80+dhadd+hadd,145,18,onprot.val,"Only place doodads on protrusions")
  1398.     
  1399.     #Doodad Properties
  1400.     glColor3f(0.0,0.0,0.0)
  1401.     glRasterPos2d(12+dwadd+wadd, 63+dhadd+hadd)
  1402.     Text("Doodad Properties:")
  1403.     BeginAlign()
  1404.     doodadminamount = Number("Min Amount: ",EVENT_NONE,12+dwadd+wadd,40+dhadd+hadd,145,18,doodadminamount.val,0,100,"Minimum number of doodads per face")
  1405.     doodadmaxamount = Number("Max Amount: ",EVENT_NONE,162+dwadd+wadd,40+dhadd+hadd,145,18,doodadmaxamount.val,0,100,"Maximum number of doodads per face")
  1406.     EndAlign()
  1407.     BeginAlign()
  1408.     doodheightmin = Number("Min Height: ",EVENT_NONE,12+dwadd+wadd,20+dhadd+hadd,145,18,doodheightmin.val,0.0,100.0,"Minimum height of any doodad")
  1409.     doodheightmax = Number("Max Height: ",EVENT_NONE,162+dwadd+wadd,20+dhadd+hadd,145,18,doodheightmax.val,0.0,100.0,"Maximum height of any doodad")
  1410.     EndAlign()
  1411.     BeginAlign()
  1412.     doodsizemin = Number("Min Size %: ",EVENT_NONE,12+dwadd+wadd,dhadd+hadd,145,18,doodsizemin.val,0.0,100.0,"Minimum size of any doodad in percentage of face")
  1413.     doodsizemax = Number("Max Size %: ",EVENT_NONE,162+dwadd+wadd,dhadd+hadd,145,18,doodsizemax.val,0.0,100.0,"Maximum size of any doodad in percentage of face")
  1414.     EndAlign()
  1415.     
  1416.     #Materials
  1417.     colorbox(8+mwadd+wadd,93+mhadd+hadd,312+mwadd+wadd,mhadd-5+hadd)
  1418.     glColor3f(0.0,0.0,0.0)
  1419.     glRasterPos2d(12+mwadd+wadd, 83+mhadd+hadd)
  1420.     Text("Materials:")
  1421.     glRasterPos2d(12+mwadd+wadd, 43+mhadd+hadd)
  1422.     Text("Assigned Material Indices:")
  1423.     assignNewMats = Toggle("Assign materials by part",EVENT_NONE,32+mwadd+wadd,60+mhadd+hadd,256,18,assignNewMats.val,"Otherwise, previous materials will be preserved")
  1424.     replProtSideIndex = Number("Protrusion Sides:",EVENT_NONE,12+mwadd+wadd,20+mhadd+hadd,145,18,replProtSideIndex.val,0,16,"Material index assigned to sides of protrusions")
  1425.     replProtTopIndex = Number("Protrusion Tops:",EVENT_NONE,162+mwadd+wadd,20+mhadd+hadd,145,18,replProtTopIndex.val,0,16,"Material index assigned to tops of protrusions")
  1426.     replDoodSideIndex = Number("Doodad Sides:",EVENT_NONE,12+mwadd+wadd,mhadd+hadd,145,18,replDoodSideIndex.val,0,16,"Material index assigned to sides of doodads")
  1427.     replDoodTopIndex = Number("Doodad Tops:",EVENT_NONE,162+mwadd+wadd,mhadd+hadd,145,18,replDoodTopIndex.val,0,16,"Material index assigned to tops and bottoms of doodads")
  1428.     
  1429.     #Global Parts
  1430.     colorbox(8+gwadd+wadd,35+ghadd+hadd,312+gwadd+wadd,ghadd-5+hadd)
  1431.     glColor3f(1.0,0.0,0.0)
  1432.     glRasterPos2d(12+gwadd+wadd,25+ghadd+hadd)
  1433.     messagetext = Text(errortext)
  1434.     glColor3f(0.0,0.0,0.0)
  1435.     makenewobject = Toggle("Copy Before Modifying",EVENT_NONE,162+gwadd+wadd,ghadd+hadd,145,18,makenewobject.val,"If selected, the original object will be copied before it is changed")
  1436.     Button("Discombobulate",EVENT_DISCOMBOBULATE,12+gwadd+wadd,ghadd+hadd,100,18)
  1437.     Button("Exit",EVENT_EXIT,120+gwadd+wadd,ghadd+hadd,30,18)
  1438.  
  1439. def event(evt, val):
  1440.     global wadd
  1441.     global hadd
  1442.     
  1443.     if (evt == RIGHTARROWKEY and val):
  1444.         wadd = wadd + 20
  1445.         Redraw(1)
  1446.     if (evt == LEFTARROWKEY and val):
  1447.         wadd = wadd - 20
  1448.         Redraw(1)
  1449.     if (evt == UPARROWKEY and val):
  1450.         hadd = hadd + 20
  1451.         Redraw(1)
  1452.     if (evt == DOWNARROWKEY and val):
  1453.         hadd = hadd - 20
  1454.         Redraw(1)
  1455.     if (evt == QKEY and not val): 
  1456.         Exit()
  1457.  
  1458. def bevent(evt):
  1459.     
  1460.     #Protrusions
  1461.     global doprots
  1462.     global facechange
  1463.     global minheight
  1464.     global maxheight
  1465.     global sub1
  1466.     global sub2
  1467.     global sub3
  1468.     global sub4
  1469.     global mintaper
  1470.     global maxtaper
  1471.     global useselected
  1472.     global selface1
  1473.     global selface2
  1474.     global selface3
  1475.     global selface4
  1476.     global deselectvertices
  1477.     #global selectbyverts
  1478.     
  1479.     #Doodads
  1480.     global dodoodads
  1481.     global doodadfacechange
  1482.     global seldoodad
  1483.     global onprot
  1484.     global dood1
  1485.     global dood2
  1486.     global dood3
  1487.     global dood4
  1488.     global dood5
  1489.     global dood6
  1490.     global doodadminamount
  1491.     global doodadmaxamount
  1492.     global doodsizemin
  1493.     global doodsizemax
  1494.     global doodheightmin
  1495.     global doodheightmax
  1496.     global doodonselface
  1497.     global seldoodtop
  1498.     
  1499.     #Materials
  1500.     global assignNewMats
  1501.     global replProtSideIndex
  1502.     global replProtTopIndex
  1503.     global replDoodSideIndex
  1504.     global replDoodTopIndex
  1505.     
  1506.     #Global Settings
  1507.     global makenewobject
  1508.     global messagetext
  1509.     global errortext
  1510.     global EVENT_NONE,EVENT_DRAW,EVENT_EXIT
  1511.  
  1512.     ######### Manages GUI events
  1513.     if evt==EVENT_EXIT: 
  1514.         Exit()
  1515.     elif evt==EVENT_DISCOMBOBULATE:
  1516.         Window.WaitCursor(1)
  1517.         setProtrusionValues(doprots.val,facechange.val/100,minheight.val,maxheight.val,sub1.val,sub2.val,sub3.val,sub4.val,mintaper.val/100,maxtaper.val/100,useselected.val,selface1.val,selface2.val,selface3.val,selface4.val,deselectvertices.val)
  1518.         setDoodadValues(dodoodads.val,doodadfacechange.val/100,seldoodad.val,onprot.val,dood1.val,dood2.val,dood3.val,dood4.val,dood5.val,dood6.val,doodadminamount.val,doodadmaxamount.val,doodsizemin.val/100,doodsizemax.val/100,doodheightmin.val,doodheightmax.val,doodonselface.val,seldoodtop.val)
  1519.         setOtherValues(makenewobject.val,assignNewMats.val,replProtSideIndex.val,replProtTopIndex.val,replDoodSideIndex.val,replDoodTopIndex.val)
  1520.         discombobulate()
  1521.         Window.WaitCursor(0)
  1522.         Blender.Redraw()
  1523.  
  1524. Register(draw, event, bevent)
  1525.